<?php

/**
 * contact : 刘经理 19326416371
 * company : 版权所属 四川北星惯牌科技有限公司
 **/

namespace app\common\behavior;

use app\common\manager\LogManager;
use think\Exception;
use function fast\e;

class Log
{

    public function run(&$params)
    {
        try {
            if (empty($params['username']) || empty($params['user_id']) || empty($params['data']) || empty($params['match_id']) || empty($params['start_time']) || empty($params['end_time']) || empty($params['type']) || empty($params['redirect'])) {
                throw new Exception('数据不全');
            }

            $result = LogManager::Log($params['username'],$params['user_id'],$params['tips'],$params['data'],$params['match_id'],$params['start_time'],$params['end_time'],$params['type'],$params['redirect']);
            if ($result['code'] != LogManager::$successCode){
                throw new Exception($result['message']);
            }

        }catch (Exception $exception){
            file_put_contents('log.txt',$exception->getMessage().$exception->getLine().PHP_EOL,FILE_APPEND);
        }

    }

}
